//
//  AllInvoiceViewController.m
//  TeamInformatization
//
//  Created by Jessica on 2019/4/7.
//  Copyright © 2019 SPIC. All rights reserved.
//

#import "AllInvoiceViewController.h"
#import "AllInvoiceViewCell.h"
#import "AllInvoice.h"
@interface AllInvoiceViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *invioceListTableView;

// data
@property (nonatomic, strong) NSMutableArray *invoiceListArray;
@end

@implementation AllInvoiceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self showTitleBarWithTitle:_contentTitle leftButtonStyle:Base_NavigationBar_Back rightButtonStyle:Base_NavigationBar_Back_Home];
    // 初始数据
    self.invoiceListArray = [NSMutableArray arrayWithCapacity:0];
    for (int i = 0; i < 7; i++) {
        AllInvoice *invoice = [[AllInvoice alloc] init];
        invoice.title = @"电力机房添加新设备——控制…";
        invoice.status = @"许可";
        invoice.descriptions = @"2019-03-30 09:40:32";
        [self.invoiceListArray addObject:invoice];
    }
    
    // UI
    [self loadShowViews];
}

// UI
- (void)loadShowViews
{
    
    self.invioceListTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, kSafeAreaTopHeight + 60 * kScaleHeight, kScreenWidth, kSecondContentHeight - 40 * kScaleWidth) style:UITableViewStylePlain];
    [_invioceListTableView registerClass:[AllInvoiceViewCell class] forCellReuseIdentifier:@"AllInvoiceViewCell"];
    _invioceListTableView.delegate = self;
    _invioceListTableView.dataSource = self;
    _invioceListTableView.backgroundColor = [UIColor clearColor];
    _invioceListTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _invioceListTableView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:_invioceListTableView];
    
}

#pragma mark - TableViewDelegate/DataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _invoiceListArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 127 * kScaleHeight;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    AllInvoice *invoice = [[AllInvoice alloc] init];
    if (self.invoiceListArray.count != 0) {
        invoice = self.invoiceListArray[indexPath.row];
    }
    
    AllInvoiceViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AllInvoiceViewCell" forIndexPath:indexPath];
    if (!cell) {
        cell = [[AllInvoiceViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"AllInvoiceViewCell"];
    }
    
    [cell setShowCellWithInvoice:invoice];
    
    return cell;
    
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
}


#pragma -导航栏 两边按钮操作
-(void)baseNavigationBarLeftButtonClick:(UIButton *)button
{
    [self.navigationController popViewControllerAnimated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
